<?php
namespace app\admin\model;
use think\Db;
use think\Model;

class ShareModel extends Model
{
	 public function __construct()
    {
        parent::__construct();

    }
    public function getShareList($page,$limit,$map=array(),$field='*')
    {
    	return Db::name('share')->page($page,$limit)->where($map)
            ->order('share_id desc')->field($field)->select();
    }

    public function addShare($data,$flag=false)
    {
        if($flag){
            Db::name('share')->insertAll($data);
            return Db::name('share')->getLastInsID();
        }
        return Db::name('share')->insertGetId($data);
    }

    public function updateShare($map,$data)
    {
        return Db::name('share')->where($map)->update($data);
    }

    public function getShareById($id,$field='*')
    {
        return Db::name('share')->where(array('share_id'=>$id))->field($field)->find();
    }

    public function searchShare($map,$field='*')
    {
        return Db::name('share')->where($map)->order('share_id desc')->column($field);
    }
}
